<template>
	<view class="page">
		<view class="info_box">
			<view class="info_box_base">
				<view class="info_box_base_title" style="font-weight: bold;">站点信息</view>
				<view class="info_box_base_item">所属地区：{{baseInfo.region}}</view>
				<view class="info_box_base_item">站点编号：{{baseInfo.site_number}}</view>
				<view class="info_box_base_item" v-if="baseInfo.operators == 1">运营商：中国移动</view>
				<view class="info_box_base_item" v-if="baseInfo.operators == 2">运营商：中国电信</view>
				<view class="info_box_base_item" v-if="baseInfo.operators == 3">运营商：中国联通</view>
				<view class="info_box_base_item">站点名称：{{baseInfo.title}}</view>
				<view class="info_box_base_item">站点地址：{{baseInfo.site_address}}</view>
				<view class="info_box_base_item">联系人及电话：{{baseInfo.contacts}} {{baseInfo.phonetel}}</view>
				<view class="info_box_base_item">经纬度：经度: {{params_old.longitude}} 纬度: {{params_old.latitude}} </view>
				<view class="info_box_base_item">网络类型： {{wllxText}}</view>
				<view class="info_box_base_item">计划覆盖面积： {{params_old.planned_coverage_area}}</view>
				<view class="info_box_base_item">计划覆盖区域描述： {{params_old.descriptionof_plannedcoveragearea}}</view>
				<view class="info_box_base_item">设计方案：<text class="down_link" @click="down()">点击链接下载</text></view>
				<view class="info_box_base_item" style="color: red;" v-if="baseInfo.status == 3">拒绝原因：<text class="base_item_dd">{{baseInfo.rejection}}</text></view>
				<view class="info_box_base_item">设备型号：{{params_old.equipment_model}}</view>
				<view class="info_box_base_item_1" style="margin: 10rpx 0;">
					<view class="info_box_base_item_img_title">设备材料数量：</view>
					<view class="info_box_base_item_1_item" style="display: flex;flex-direction: row;flex-wrap: wrap;">
						<view class="info_box_base_item_1_item_i">
							<text>接收设备：</text>
							<text>{{params.equi_mater_receivingdevice}}</text>
							<!-- <u--input value="1" disabled v-model="params.equi_mater_receivingdevice" border="bottom"></u--input> -->
						</view>
						<view class="info_box_base_item_1_item_i">
							<text>覆盖设备：</text>
							<text>{{params.equi_mater_coveragedevice}}</text>
							<!-- <u--input border="bottom" disabled v-model="params.equi_mater_coveragedevice"></u--input> -->
						</view>
						<view class="info_box_base_item_1_item_i">
							<text>4口扩展：</text>
							<text>{{params.port_4expansion}}</text>
							<!-- <u--input border="bottom" disabled v-model="params.port_4expansion"></u--input> -->
						</view>
						<view class="info_box_base_item_1_item_i">
							<text>8口扩展：</text>
							<text>{{params.port_8expansion}}</text>
							<!-- <u--input border="bottom" disabled v-model="params.port_8expansion"></u--input> -->
						</view>
						<view class="info_box_base_item_1_item_i">
							<text>1/2馈线：</text>
							<text>{{params.feeder}}</text>
							<!-- <u--input border="bottom" disabled v-model="params.feeder"></u--input> -->
						</view>
						<view class="info_box_base_item_1_item_i">
							<text>1/2接头：</text>
							<text>{{params.joint}}</text>
							<!-- <u--input border="bottom" disabled v-model="params.joint"></u--input> -->
						</view>
					</view>
				</view>
				<view class="info_box_base_item">数量说明：{{params_old.quantity_desc}}</view>
				<view class="info_box_base_item">计划开工时间：{{params_old.planned_start_time}}</view>
				<view class="info_box_base_item">工单说明：{{params_old.work_orderdesc}}</view>
			</view>


			<view class="info_box_base">
				<view class="info_box_base_title" style="font-weight: bold;">施工条件确认</view>
				<view class="gcxt_b_wy">
					<u-checkbox-group @change="chooseTj" v-model="params.designinstallcond_id"
						style="width: 690rpx;flex-wrap: wrap;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
						<u-checkbox size="13" v-for="(item,index) in sjanlist" style="width: 33%;margin-bottom: 20rpx;"
							labelSize="13" :name="item.id" :label="item.title"></u-checkbox>
					</u-checkbox-group>

					<!-- <u-checkbox-group style="width: 690rpx;flex-wrap: wrap;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
						<u-checkbox size="13" style="width: 33%;margin-bottom: 20rpx;" labelSize="13" label="室外基站信源"></u-checkbox>
						<u-checkbox size="13" style="width: 33%;margin-bottom: 20rpx;" labelSize="13" label="接收设备安装"></u-checkbox>
						<u-checkbox size="13" style="width: 33%;margin-bottom: 20rpx;" labelSize="13" label="覆盖设备安装"></u-checkbox>
						<u-checkbox size="13" style="width: 33%;margin-bottom: 20rpx;" labelSize="13" label="扩展设备安装"></u-checkbox>
						<u-checkbox  size="13" style="width: 33%;margin-bottom: 20rpx;" labelSize="13" label="线缆布放路由"></u-checkbox>
						<u-checkbox size="13" style="width: 33%;margin-bottom: 20rpx;" labelSize="13" label="室外天线安装"></u-checkbox>
						<u-checkbox size="13" style="width: 33%;margin-bottom: 20rpx;" labelSize="13" label="电源接入"></u-checkbox>
						<u-checkbox size="13" style="width: 33%;margin-bottom: 20rpx;" labelSize="13" label="待定"></u-checkbox>
					 	
					 </u-checkbox-group> -->
				</view>
				<view class="gcxt_b_wy_reason">
					<text sty>其他说明：</text>
					<u--input placeholder="请输入具体说明" v-model="params.other_instructions" border="none"></u--input>
				</view>
			</view>

			<view class="btn" @click="next">下一步</view>
		</view>
	</view>
</template>

<script>
	import {
		api,
		apiBaseUrl,
		http
	} from '@/config/common.js'
	export default {
		data() {
			return {
				wllx:[],
				wllxText:'',
				
				id: '',
				baseInfo: {},
				sjanlist: [],
				params_old: {},
				params: {
					equi_mater_receivingdevice: 1,
					equi_mater_coveragedevice: '',
					port_4expansion: '',
					port_8expansion: '',
					feeder: '',
					joint: "",
					designinstallcond_id: [],
					other_instructions: ''
				}
			}
		},
		components: {},
		filters: {},
		mounted() {},
		onLoad(e) { 
			this.id = e.id
			this.getSjAzTj()
			this.getBaseInfo()
			this.lookInfo()
			this.getWlle()
		},
		onShow() { 
			if(this.id){
				this.lookInfo()
			}
		},
		onPageScroll(e) {},
		beforeDestroy() {},
		methods: {
			chooseTj(e) {
				this.params.designinstallcond_id = e
			},
			//设计安装条件
			getSjAzTj() {
				uni.showLoading({})
				api.post('/api/shop/survey_siteinfo_designinstallcond', {}).then(res => {
					let rst = res.data
					uni.hideLoading()
					if (rst.code == 1) {
						this.sjanlist = rst.data
					}

				}).catch(err => {
					uni.hideLoading()
				})
			},
			//网络类型
			getWlle() {
				uni.showLoading({})
				api.post('/api/shop/survey_network_type', {}).then(res => {
					let rst = res.data
					uni.hideLoading()
					if (rst.code == 1) {
						let rstt = rst.data
						rstt.map(function(item) {
							item.name = item.title
						})
						this.wllx = rst.data
					}
				}).catch(err => {
					uni.hideLoading()
				})
			},
			down() {
				window.open(this.baseInfo.design_scheme, '_blank'); 
			},

			getBaseInfo() {
				uni.showLoading({})
				api.post('/api/shop/look_eeringinstall', {
					engin_id: this.id
				}).then(res => {
					let rst = res.data
					uni.hideLoading()
					if (rst.code == 1) {
						this.baseInfo = rst.data
						console.log(rst.data)
					}

				}).catch(err => {
					uni.hideLoading()
				})
			},
			lookInfo() {
				uni.showLoading({})
				api.post('api/shop/submit_eeringinstall', {
					engin_id: this.id,
					type: 2
				}).then(res => {
					uni.hideLoading()
					let rst = res.data
					if (rst.code == 1) { 
						
						this.$nextTick(() => {
							let wllxText = [];
							this.wllx.forEach(function(item){ 
								rst.data.network_type_id.forEach(function(itemm){ 
									if (item.id == itemm){ 
										wllxText.push(item.name)  
									}
								}) 
							})   
							this.wllxText = wllxText.join(',') 
						})
						
						
						if (res.data) {
							rst.data.designinstallcond_id = rst.data.designinstallcond_id?rst.data.designinstallcond_id.map(item => parseInt(item,10)):[]
							this.params = rst.data 
							this.params.equi_mater_receivingdevice = 1
							this.params_old = rst.data 
						}

					}

				}).catch(err => {
					uni.hideLoading()
				})
			},
			next() {
				let rst = this.params

				// let temp_val = Object.values(rst);
				// const hasEmptyValue = temp_val.some(item => !item);
				// if (hasEmptyValue) {
				// 	uni.$u.toast("请填写完整内容")
				// 	return;
				// }
				 
				if (Array.isArray(rst.designinstallcond_id)) {
				   rst.designinstallcond_id = rst.designinstallcond_id.join(",")
				}
				
				uni.showLoading({})
				api.post('api/shop/submit_eeringinstall', {
					engin_id: this.id,
					...rst,
					type: 1
				}).then(res => {
					let rsttt = res.data
					uni.hideLoading()
					if (rsttt.code == 1) {
						uni.navigateTo({
							url: '/pages/gcaz/azsg?id=' + this.id
						})
					} else {
						uni.$u.toast(rsttt.msg)
					}
				}).catch(err => {
					uni.hideLoading()
				})
			}
		}
	};
</script>

<style scoped>
	.base_item_dd{
		word-wrap: break-word;
		overflow-wrap: break-word;
		white-space: normal;
		width: 80%;
	}
	.info_box_base_item_1_item_i {
		width: 30%;
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-left: 3%;
		margin-top: 15rpx;
	}

	.down_link {
		color: rgb(11, 125, 218);
		font-size: 25rpx;
	}

	.btn {
		width: 500rpx;
		height: 80rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
		margin: 0 auto;
		margin-top: 40rpx;
		background-color: rgb(70, 179, 255);
		color: #fff;
		border-radius: 40rpx;
		font-size: 32rpx;
	}

	::v-deep .uni-input-input {
		font-size: 26rpx;
	}

	::v-deep .uni-input-placeholder {
		font-size: 26rpx;
	}

	.gcxt_b_wy_reason {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.gcxt_b_wy {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin: 20rpx 0;
	}

	.info_box_base {
		border: 1px solid rgb(235, 229, 229);
		padding: 20rpx;
		font-size: 26rpx;
		margin-top: 20rpx;
	}

	.info_box_base_item {
		line-height: 50rpx;
		word-wrap: break-word;
		/* 允许在单词内换行 */
		overflow-wrap: break-word;
		/* 同上，现代浏览器推荐使用这个属性别名 */
		white-space: normal;
		/* 允许自动换行 */
	}

	.info_box {
		width: 710rpx;
		margin: 0 auto;
		padding-bottom: 40rpx;
	}

	page {
		background-color: #fff;
	}
</style>